﻿using Microsoft.Extensions.Caching.Distributed;
using System;
using System.Collections.Generic;
using System.Text;

namespace Cms.Core.Application.Secutiry.Base
{
    /// <summary>
    /// 在线缓存抽象类
    /// </summary>
    public abstract class OnlineCacheAbstract
    {

        /// <summary>
        /// 
        /// </summary>
        /// <param name="offset"></param>
        /// <returns></returns>
        public virtual DistributedCacheEntryOptions SetSlidingExpiration(TimeSpan offset)
        {
            DistributedCacheEntryOptions options = new DistributedCacheEntryOptions();
            options.SetSlidingExpiration(offset);
            return options;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="offset"></param>
        /// <returns></returns>
        public virtual DistributedCacheEntryOptions SetAbsoluteExpiration(TimeSpan offset)
        {
            DistributedCacheEntryOptions options = new DistributedCacheEntryOptions();
            options.SetAbsoluteExpiration(offset);
            return options;
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="absolute"></param>
        /// <returns></returns>
        public virtual DistributedCacheEntryOptions SetAbsoluteExpiration(DateTimeOffset absolute)
        {
            DistributedCacheEntryOptions options = new DistributedCacheEntryOptions();
            options.SetAbsoluteExpiration(absolute);
            return options;
        }
    }
}
